import 'package:flutter/material.dart';
import 'package:core_package/core_package.dart';

class PromotionOrderWidget extends StatefulWidget {
  @override
  _PromotionOrderWidgetState createState() => _PromotionOrderWidgetState();
}

class _PromotionOrderWidgetState extends State<PromotionOrderWidget> with AutomaticKeepAliveClientMixin {
  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        MySizeBox(height: 25.px),
        buildTitleWidget(),
        MySizeBox(height: 5),
        buildListWidget(),
        MySizeBox(height: 5),
      ],
    );
  }

  Widget buildListWidget() {
    return Expanded(
      child: ListView.builder(
        padding: EdgeInsets.zero,
        itemCount: 10,
        itemBuilder: (ctx, index) {
          return buildListItemWidget("2012-12", "你好", "已完成", "20000");
        },
      ),
    );
  }

  Widget buildListItemWidget(String date, String type, String status, String number) {
    return Padding(
      padding: EdgeInsets.symmetric(vertical: 5.px),
      child: Row(
        children: [
          buildItemTextWidget(date),
          buildItemTextWidget(type),
          buildItemTextWidget(status),
          buildItemTextWidget(number),
        ],
      ),
    );
  }

  Widget buildItemTextWidget(String string) {
    return Container(
      alignment: Alignment.center,
      width: SizeFill.screenWidth! / 4 - 5.px,
      child: Text(
        string,
        style: TextStyle(
          color: MyColors.color_27_27_27,
          fontWeight: MyFontWeight.regular,
          fontSize: MyFont.font10,
        ),
      ),
    );
  }

  Widget buildTitleWidget() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: [
        buildTitleItemWidget("日期", () {}),
        buildTitleItemWidget("推广类型", () {}),
        buildTitleItemWidget("推广进度", () {}),
        buildTitleItemWidget("金币数量", () {}),
      ],
    );
  }

  Widget buildTitleItemWidget(String title, Function() onTap) {
    return Container(
      width: SizeFill.screenWidth! / 4 - 5.px,
      alignment: Alignment.center,
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          Text(
            title,
            style: TextStyle(
              color: MyColors.color_27_27_27,
              fontSize: MyFont.font13,
              fontWeight: MyFontWeight.regular,
            ),
          ),
          SizedBox(width: 2),
          Icon(
            Icons.arrow_drop_down,
            size: 15.px,
            color: MyColors.color_27_27_27,
          ),
        ],
      ),
    );
  }
}
